// 检查用户是否已登录
export const isAuthenticated = (): boolean => {
  const token = localStorage.getItem('token');
  return !!token;
};

// 获取用户信息
export const getUserInfo = () => {
  const userInfoStr = localStorage.getItem('userInfo');
  if (userInfoStr) {
    try {
      return JSON.parse(userInfoStr);
    } catch (error) {
      return null;
    }
  }
  return null;
};

// 登出
export const logout = () => {
  localStorage.removeItem('token');
  localStorage.removeItem('userInfo');
}; 